package tw.com.softleader.json.jackson.app;

import java.io.InputStream;

import tw.com.softleader.json.jackson.entity.Question07Animal;
import tw.com.softleader.json.jackson.entity.Question07Pets;

import com.fasterxml.jackson.databind.ObjectMapper;

public class Question07App {

	public static void main(String[] args) {
		
		// Read file as InputStream..
		InputStream in = Question07App.class.getResourceAsStream("/question07.json");
		
		Question07Pets pets = null;
		try {
			// TODO 請將 dog 載入 question07.json 的資料, 請注意是Dog,Cat 和 Animal 有繼承關係
			// 請根據 question07.json 的資料在 Animal (parent) 物件增加 annotation 來讓不同的子物件設值.
			ObjectMapper m = new ObjectMapper();
			pets =  m.readValue(in, Question07Pets.class);
			
			for(Question07Animal pet:pets.getPets()) {
				System.out.println(pet);
			}
			
			
		} catch (Exception e) {
			e.printStackTrace();
		} 
		
	
	}
	
}
